package o;

import android.graphics.Rect;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.util.ArrayList;
import java.util.List;
import o.ja.a;
import o.ja.b;

public abstract class jb extends hc {
    private static final a<in> ˋॱ = new a<in>() {
        public void ˋ(in inVar, Rect rect) {
            inVar.ˏ(rect);
        }
    };
    private static final b<dz<in>, in> ˏॱ = new b<dz<in>, in>() {
        public /* synthetic */ Object ˎ(Object obj, int i) {
            return ˊ((dz) obj, i);
        }

        public /* synthetic */ int ॱ(Object obj) {
            return ˎ((dz) obj);
        }

        public in ˊ(dz<in> dzVar, int i) {
            return (in) dzVar.ˎ(i);
        }

        public int ˎ(dz<in> dzVar) {
            return dzVar.ˋ();
        }
    };
    private static final Rect ॱ = new Rect(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED, Integer.MIN_VALUE, Integer.MIN_VALUE);
    private final Rect ʻ = new Rect();
    private c ʼ;
    private final AccessibilityManager ʽ;
    int ˊ = Integer.MIN_VALUE;
    public int ˊॱ = Integer.MIN_VALUE;
    private final Rect ˋ = new Rect();
    int ˎ = Integer.MIN_VALUE;
    private final Rect ˏ = new Rect();
    private final int[] ॱॱ = new int[2];
    private final View ᐝ;

    class c extends im {
        final /* synthetic */ jb ˎ;

        c(jb jbVar) {
            this.ˎ = jbVar;
        }

        public in ˋ(int i) {
            return in.ˎ(this.ˎ.ˋ(i));
        }

        public boolean ˋ(int i, int i2, Bundle bundle) {
            return this.ˎ.ˊ(i, i2, bundle);
        }

        public in ˊ(int i) {
            int i2 = i == 2 ? this.ˎ.ˎ : this.ˎ.ˊ;
            if (i2 == Integer.MIN_VALUE) {
                return null;
            }
            return ˋ(i2);
        }
    }

    protected abstract int ˊ(float f, float f2);

    protected abstract void ˎ(List<Integer> list);

    protected abstract void ॱ(int i, @NonNull in inVar);

    protected abstract boolean ॱ(int i, int i2, @Nullable Bundle bundle);

    public jb(@NonNull View view) {
        if (view == null) {
            throw new IllegalArgumentException("View may not be null");
        }
        this.ᐝ = view;
        this.ʽ = (AccessibilityManager) view.getContext().getSystemService("accessibility");
        view.setFocusable(true);
        if (ViewCompat.getImportantForAccessibility(view) == 0) {
            ViewCompat.setImportantForAccessibility(view, 1);
        }
    }

    public im ˋ(View view) {
        if (this.ʼ == null) {
            this.ʼ = new c(this);
        }
        return this.ʼ;
    }

    public final boolean ˏ(@NonNull MotionEvent motionEvent) {
        boolean z = true;
        if (!this.ʽ.isEnabled() || !this.ʽ.isTouchExplorationEnabled()) {
            return false;
        }
        switch (motionEvent.getAction()) {
            case 7:
            case 9:
                int ˊ = ˊ(motionEvent.getX(), motionEvent.getY());
                ॱ(ˊ);
                if (ˊ == Integer.MIN_VALUE) {
                    z = false;
                }
                return z;
            case 10:
                if (this.ˊॱ == Integer.MIN_VALUE) {
                    return false;
                }
                ॱ(Integer.MIN_VALUE);
                return true;
            default:
                return false;
        }
    }

    public final boolean ˋ(@NonNull KeyEvent keyEvent) {
        boolean z = false;
        if (keyEvent.getAction() == 1) {
            return false;
        }
        int keyCode = keyEvent.getKeyCode();
        switch (keyCode) {
            case 19:
            case 20:
            case 21:
            case 22:
                if (!keyEvent.hasNoModifiers()) {
                    return false;
                }
                int ˏ = ˏ(keyCode);
                int repeatCount = keyEvent.getRepeatCount() + 1;
                keyCode = 0;
                while (keyCode < repeatCount && ˊ(ˏ, null)) {
                    keyCode++;
                    z = true;
                }
                return z;
            case 23:
            case o.fc.c.ꓸॱ /*66*/:
                if (!keyEvent.hasNoModifiers() || keyEvent.getRepeatCount() != 0) {
                    return false;
                }
                ˋ();
                return true;
            case o.fc.c.ᵢ /*61*/:
                if (keyEvent.hasNoModifiers()) {
                    return ˊ(2, null);
                }
                if (keyEvent.hasModifiers(1)) {
                    return ˊ(1, null);
                }
                return false;
            default:
                return false;
        }
    }

    public final void ॱ(boolean z, int i, @Nullable Rect rect) {
        if (this.ˊ != Integer.MIN_VALUE) {
            ˎ(this.ˊ);
        }
        if (z) {
            ˊ(i, rect);
        }
    }

    private static int ˏ(int i) {
        switch (i) {
            case 19:
                return 33;
            case 21:
                return 17;
            case 22:
                return 66;
            default:
                return 130;
        }
    }

    private void ˏ(int i, Rect rect) {
        ˋ(i).ˏ(rect);
    }

    private boolean ˊ(int i, @Nullable Rect rect) {
        int i2;
        boolean z = true;
        dz ˏ = ˏ();
        int i3 = this.ˊ;
        if (i3 == Integer.MIN_VALUE) {
            Object obj = null;
        } else {
            in inVar = (in) ˏ.ˊ(i3);
        }
        switch (i) {
            case 1:
            case 2:
                if (ViewCompat.ʼ(this.ᐝ) != 1) {
                    z = false;
                }
                Object obj2 = (in) ja.ॱ(ˏ, ˏॱ, ˋॱ, obj, i, z, false);
                break;
            case 17:
            case 33:
            case o.fc.c.ꓸॱ /*66*/:
            case 130:
                Rect rect2 = new Rect();
                if (this.ˊ != Integer.MIN_VALUE) {
                    ˏ(this.ˊ, rect2);
                } else if (rect != null) {
                    rect2.set(rect);
                } else {
                    ˊ(this.ᐝ, i, rect2);
                }
                in inVar2 = (in) ja.ˏ(ˏ, ˏॱ, ˋॱ, obj, rect2, i);
                break;
            default:
                throw new IllegalArgumentException("direction must be one of {FOCUS_FORWARD, FOCUS_BACKWARD, FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}.");
        }
        if (obj2 == null) {
            i2 = Integer.MIN_VALUE;
        } else {
            i2 = ˏ.ˋ(ˏ.ˏ(obj2));
        }
        return ˊ(i2);
    }

    private dz<in> ˏ() {
        List arrayList = new ArrayList();
        ˎ(arrayList);
        dz<in> dzVar = new dz();
        for (int i = 0; i < arrayList.size(); i++) {
            dzVar.ˋ(i, ʼ(i));
        }
        return dzVar;
    }

    private static Rect ˊ(@NonNull View view, int i, @NonNull Rect rect) {
        int width = view.getWidth();
        int height = view.getHeight();
        switch (i) {
            case 17:
                rect.set(width, 0, width, height);
                break;
            case 33:
                rect.set(0, height, width, height);
                break;
            case o.fc.c.ꓸॱ /*66*/:
                rect.set(-1, 0, -1, height);
                break;
            case 130:
                rect.set(0, -1, width, -1);
                break;
            default:
                throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}.");
        }
        return rect;
    }

    private boolean ˋ() {
        return this.ˊ != Integer.MIN_VALUE && ॱ(this.ˊ, 16, null);
    }

    public final boolean ˎ(int i, int i2) {
        if (i == Integer.MIN_VALUE || !this.ʽ.isEnabled()) {
            return false;
        }
        ViewParent parent = this.ᐝ.getParent();
        if (parent == null) {
            return false;
        }
        return ie.ˋ(parent, this.ᐝ, ˏ(i, i2));
    }

    protected void ˊ(int i, boolean z) {
    }

    public void ॱ(int i) {
        if (this.ˊॱ != i) {
            int i2 = this.ˊॱ;
            this.ˊॱ = i;
            ˎ(i, (int) DnsConfig.MAX_CACHE_ENTRIES);
            ˎ(i2, 256);
        }
    }

    private AccessibilityEvent ˏ(int i, int i2) {
        switch (i) {
            case -1:
                return ᐝ(i2);
            default:
                return ॱ(i, i2);
        }
    }

    private AccessibilityEvent ᐝ(int i) {
        AccessibilityEvent obtain = AccessibilityEvent.obtain(i);
        this.ᐝ.onInitializeAccessibilityEvent(obtain);
        return obtain;
    }

    public void ˎ(View view, AccessibilityEvent accessibilityEvent) {
        super.ˎ(view, accessibilityEvent);
        ॱ(accessibilityEvent);
    }

    private AccessibilityEvent ॱ(int i, int i2) {
        AccessibilityEvent obtain = AccessibilityEvent.obtain(i2);
        in ˋ = ˋ(i);
        obtain.getText().add(ˋ.ॱˋ());
        obtain.setContentDescription(ˋ.ʾ());
        obtain.setScrollable(ˋ.ᐝॱ());
        obtain.setPassword(ˋ.ॱᐝ());
        obtain.setEnabled(ˋ.ͺ());
        obtain.setChecked(ˋ.ʽ());
        ॱ(i, obtain);
        if (obtain.getText().isEmpty() && obtain.getContentDescription() == null) {
            throw new RuntimeException("Callbacks must add text or a content description in populateEventForVirtualViewId()");
        }
        obtain.setClassName(ˋ.ʻॱ());
        io.ˎ(obtain, this.ᐝ, i);
        obtain.setPackageName(this.ᐝ.getContext().getPackageName());
        return obtain;
    }

    @NonNull
    in ˋ(int i) {
        if (i == -1) {
            return ˎ();
        }
        return ʼ(i);
    }

    @NonNull
    private in ˎ() {
        in ˏ = in.ˏ(this.ᐝ);
        ViewCompat.ॱ(this.ᐝ, ˏ);
        List arrayList = new ArrayList();
        ˎ(arrayList);
        if (ˏ.ˎ() <= 0 || arrayList.size() <= 0) {
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                ˏ.ॱ(this.ᐝ, ((Integer) arrayList.get(i)).intValue());
            }
            return ˏ;
        }
        throw new RuntimeException("Views cannot have both real and virtual children");
    }

    public void ˋ(View view, in inVar) {
        super.ˋ(view, inVar);
        ˋ(inVar);
    }

    @NonNull
    private in ʼ(int i) {
        in ˋ = in.ˋ();
        ˋ.ᐝ(true);
        ˋ.ˋ(true);
        ˋ.ˏ("android.view.View");
        ˋ.ˊ(ॱ);
        ˋ.ˋ(ॱ);
        ˋ.ˋ(this.ᐝ);
        ॱ(i, ˋ);
        if (ˋ.ॱˋ() == null && ˋ.ʾ() == null) {
            throw new RuntimeException("Callbacks must add text or a content description in populateNodeForVirtualViewId()");
        }
        ˋ.ˏ(this.ˋ);
        if (this.ˋ.equals(ॱ)) {
            throw new RuntimeException("Callbacks must set parent bounds in populateNodeForVirtualViewId()");
        }
        int ˊ = ˋ.ˊ();
        if ((ˊ & 64) != 0) {
            throw new RuntimeException("Callbacks must not add ACTION_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()");
        } else if ((ˊ & DnsConfig.MAX_CACHE_ENTRIES) != 0) {
            throw new RuntimeException("Callbacks must not add ACTION_CLEAR_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()");
        } else {
            boolean z;
            ˋ.ˎ(this.ᐝ.getContext().getPackageName());
            ˋ.ˋ(this.ᐝ, i);
            if (this.ˎ == i) {
                ˋ.ॱॱ(true);
                ˋ.ˊ(DnsConfig.MAX_CACHE_ENTRIES);
            } else {
                ˋ.ॱॱ(false);
                ˋ.ˊ(64);
            }
            if (this.ˊ == i) {
                z = true;
            } else {
                z = false;
            }
            if (z) {
                ˋ.ˊ(2);
            } else if (ˋ.ᐝ()) {
                ˋ.ˊ(1);
            }
            ˋ.ˊ(z);
            this.ᐝ.getLocationOnScreen(this.ॱॱ);
            ˋ.ˎ(this.ˏ);
            if (this.ˏ.equals(ॱ)) {
                ˋ.ˏ(this.ˏ);
                if (ˋ.ˋ != -1) {
                    in ˋ2 = in.ˋ();
                    for (ˊ = ˋ.ˋ; ˊ != -1; ˊ = ˋ2.ˋ) {
                        ˋ2.ˎ(this.ᐝ, -1);
                        ˋ2.ˊ(ॱ);
                        ॱ(ˊ, ˋ2);
                        ˋ2.ˏ(this.ˋ);
                        this.ˏ.offset(this.ˋ.left, this.ˋ.top);
                    }
                    ˋ2.ʽॱ();
                }
                this.ˏ.offset(this.ॱॱ[0] - this.ᐝ.getScrollX(), this.ॱॱ[1] - this.ᐝ.getScrollY());
            }
            if (this.ᐝ.getLocalVisibleRect(this.ʻ)) {
                this.ʻ.offset(this.ॱॱ[0] - this.ᐝ.getScrollX(), this.ॱॱ[1] - this.ᐝ.getScrollY());
                if (this.ˏ.intersect(this.ʻ)) {
                    ˋ.ˋ(this.ˏ);
                    if (ˏ(this.ˏ)) {
                        ˋ.ॱ(true);
                    }
                }
            }
            return ˋ;
        }
    }

    boolean ˊ(int i, int i2, Bundle bundle) {
        switch (i) {
            case -1:
                return ˋ(i2, bundle);
            default:
                return ˏ(i, i2, bundle);
        }
    }

    private boolean ˋ(int i, Bundle bundle) {
        return ViewCompat.ˊ(this.ᐝ, i, bundle);
    }

    private boolean ˏ(int i, int i2, Bundle bundle) {
        switch (i2) {
            case 1:
                return ˊ(i);
            case 2:
                return ˎ(i);
            case 64:
                return ʽ(i);
            case DnsConfig.MAX_CACHE_ENTRIES /*128*/:
                return ॱॱ(i);
            default:
                return ॱ(i, i2, bundle);
        }
    }

    private boolean ˏ(Rect rect) {
        if (rect == null || rect.isEmpty() || this.ᐝ.getWindowVisibility() != 0) {
            return false;
        }
        ViewParent parent = this.ᐝ.getParent();
        while (parent instanceof View) {
            View view = (View) parent;
            if (view.getAlpha() <= 0.0f || view.getVisibility() != 0) {
                return false;
            }
            parent = view.getParent();
        }
        return parent != null;
    }

    private boolean ʽ(int i) {
        if (!this.ʽ.isEnabled() || !this.ʽ.isTouchExplorationEnabled() || this.ˎ == i) {
            return false;
        }
        if (this.ˎ != Integer.MIN_VALUE) {
            ॱॱ(this.ˎ);
        }
        this.ˎ = i;
        this.ᐝ.invalidate();
        ˎ(i, 32768);
        return true;
    }

    private boolean ॱॱ(int i) {
        if (this.ˎ != i) {
            return false;
        }
        this.ˎ = Integer.MIN_VALUE;
        this.ᐝ.invalidate();
        ˎ(i, (int) WXMediaMessage.THUMB_LENGTH_LIMIT);
        return true;
    }

    public final boolean ˊ(int i) {
        if ((!this.ᐝ.isFocused() && !this.ᐝ.requestFocus()) || this.ˊ == i) {
            return false;
        }
        if (this.ˊ != Integer.MIN_VALUE) {
            ˎ(this.ˊ);
        }
        this.ˊ = i;
        ˊ(i, true);
        ˎ(i, 8);
        return true;
    }

    public final boolean ˎ(int i) {
        if (this.ˊ != i) {
            return false;
        }
        this.ˊ = Integer.MIN_VALUE;
        ˊ(i, false);
        ˎ(i, 8);
        return true;
    }

    protected void ॱ(int i, @NonNull AccessibilityEvent accessibilityEvent) {
    }

    protected void ॱ(@NonNull AccessibilityEvent accessibilityEvent) {
    }

    protected void ˋ(@NonNull in inVar) {
    }
}
